import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { fileURLToPath, URL } from 'node:url' // 添加这行导入
import path from 'path' // 添加这行导入

const pathResolve = (dir) => {
  return resolve(__dirname, '.', dir);
};

export default defineConfig({
  base: './',
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    open: true,
    port: 8000,
    proxy: {
      '/api': {
        target: 'http://10.1.6.130',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '/api'),

        timeout: 5000
      },
      '/icons': {
        target: 'http://10.1.6.130',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/icons/, '/icons')
      },
      '/stutasks': {
        target: 'http://10.1.6.130',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/stutasks/, '/stutasks')
      }
    }
  }
});